module.exports = app => {
    const { STRING, INTEGER, BOOLEAN } = app.Sequelize;

    const Model = app.model.define(
        'user_base',
        {
            user_id: {
                type: INTEGER,
                allowNull: false,
                unique: true
            },
            register_state: {
                type: INTEGER,
                allowNull: false
            },
            member_code: {
                type: STRING(16),
                allowNull: true
            },
            id_number: {
                type: STRING(18),
                allowNull: true
            },
            body_height: {
                type: INTEGER,
                allowNull: true
            },
            body_weight: {
                type: INTEGER,
                allowNull: true
            },
            stature_id: {
                type: INTEGER,
                allowNull: true
            },
            live_region: {
                type: STRING(32),
                allowNull: true
            },
            birth_region: {
                type: STRING(32),
                allowNull: true
            },
            marriage_state: {
                type: INTEGER,
                allowNull: true
            },
            child_state: {
                type: INTEGER,
                allowNull: true
            },
            nationality_id: {
                type: INTEGER,
                allowNull: true
            },
            month_pay: {
                type: INTEGER,
                allowNull: true
            },
            education_id: {
                type: INTEGER,
                allowNull: true
            },
            organization_id: {
                type: INTEGER,
                allowNull: true
            },
            vocation_id: {
                type: INTEGER,
                allowNull: true
            },
            university: {
                type: STRING(32),
                allowNull: true
            },
            major: {
                type: STRING(32),
                allowNull: true
            },
            house_state: {
                type: INTEGER,
                allowNull: true
            },
            loan_state: {
                type: INTEGER,
                allowNull: true
            },
            vehicle_state: {
                type: INTEGER,
                allowNull: true
            },
            smoke_state: {
                type: INTEGER,
                allowNull: true
            },
            drink_state: {
                type: INTEGER,
                allowNull: true
            },
            sport_state: {
                type: INTEGER,
                allowNull: true
            },
            marriage_plan: {
                type: INTEGER,
                allowNull: true
            },
            child_plan: {
                type: INTEGER,
                allowNull: true
            },
            introduction: {
                type: STRING,
                allowNull: true
            },
            avatar_verify: {
                type: INTEGER,
                allowNull: true
            },
            identity_verify: {
                type: INTEGER,
                allowNull: true
            },
            education_verify: {
                type: INTEGER,
                allowNull: true
            },
            single_state: {
                type: INTEGER,
                allowNull: false,
                defaultValue: 1
            },
            complaint_state: {
                type: INTEGER,
                allowNull: false,
                defaultValue: 1
            },
            bonus_points: {
                type: INTEGER,
                allowNull: false,
                defaultValue: 0
            },
            online: {
                type: BOOLEAN,
                allowNull: false,
                defaultValue: false
            }
        },
        {
            tableName: 'tbl_user_base',
            timestamps: true,
            underscored: true,
            charset: 'utf8',
            collate: 'utf8_general_ci'
        });

    Model.createTable = async () => {
        try {
            return await Model.sync({force: true});
        } catch (error) {
            return error.message;
        }
    };

    return Model;
};